/* Exclude<T,U> 强制T【不是】U的衍生类型（否则never） */
// Exclude from T those types that are assignable to U
// type Exclude<T, U> = T extends U ? never : T;
let dt11: Exclude<IPersonII, IGoods>;
let dt12: Exclude<IPersonII, IContainer>;

/* Extract<T,U> 强制T是U的衍生类（否则never） */
// Extract from T those types that are assignable to U
// type Extract<T, U> = T extends U ? T : never;
let dt21: Extract<IPersonII, IGoods>;
let dt22: Extract<IPersonII, IContainer>;

/* Record<K,T> = 对属性列表K做类型映射 */
// 简单场景：造一个key-value为指定类型的字典类型
// 例如：水果数量字典类型
type FruitCountDict = Record<string, number>;
const fruitCount: FruitCountDict = {
  apple: 3,
  banana: 5,
  orange: 2,
};

// 【人类特征描述器】
type PersonPropertyDescritor = Record<keyof IPersonII, string>
let dt3: PersonPropertyDescritor = {
  name: "人的姓名",
  price: "人的价格",
  age: "人的年龄",
  work: "人的工作函数",
};

/* Omit<T,K> 从T中忽略属性列表K */
// Construct a type with the properties of T except for those in type K.
// type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
let dt4: Omit<IPersonII, keyof IGoods> = {
  age: 0,
  work: () => "uviewwaht",
};

/* Pick<T,K> 从T中节选属性列表K形成新的接口 */
// From T, pick a set of properties whose keys are in the union K
// type Pick<T, K extends keyof T> = {
//     [P in K]: T[P];
// };
let dt5: Pick<IPersonII, "name" | "age"> = {
  name: "",
  age: 0,
};
